package com.project.internship.controller.practice;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.internship.entity.resp.RespPageBean;
import com.project.internship.service.StudentPositionService;
import com.project.internship.vo.StudentPositionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/practice/record")
public class PracticeRecordController {

    @Autowired
    StudentPositionService spService;

    @GetMapping("/")
    public RespPageBean getPracticeRecord(@RequestParam(defaultValue = "1") Integer current,
                                             @RequestParam(defaultValue = "10") Integer size,
                                             String keyword){
        Page<StudentPositionVO> page = new Page<>(current,size);
        Long total = spService.getPracticeRecord(page,keyword).getTotal();
        List<StudentPositionVO> data =  spService.getPracticeRecord(page,keyword).getRecords();

        return new RespPageBean(total,data);
    }
}
